// import { getCaptcha } from '@/api/user'
import {
  captchaImage
} from '@/api/userCenter'
import {
  setStorage
} from '@/utils'
export default {
  data() {
    return {
      loading: false, // 加载变量
      curCaptchaPath: '' // 二维码
    }
  },
  created() {
    // this.getCaptchaPath() // 获取登录验证码
  },
  methods: {
    async callWithHandlerError(cb) {
      // 统一的请求结果情况处理
      try {
        this.loading = true
        await cb()
      } catch (error) {
        this.$apiStatusHandler(99, error.message) // 异常提示处理
      } finally {
        this.loading = false  
      }
    },
    backHome() {
      // this.SET_TOKEN(this.visitor)
      this.$router.push('/platformPortal')
      setStorage('role', 'youke', 0)
    },
    cbOperation(componentName) {
      this.$emit('switchForm', componentName)
    },
    async getCaptchaPath() {
      // 获取验证码
      this.uuid = this.getUuid()
      // const data = await captchaImage(this.uuid)
      this.curCaptchaPath = `${captchaImage}?uuid=${this.uuid}`
    },
    getUuid() {
      const len = 32
      const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz'
      const maxPos = $chars.length
      let pwd = ''
      for (let i = 0; i < len; i++) {
        pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
      }
      return pwd
    }
  }
}